/**
 * @file crypt.h
 * @brief Macros of the cypher and decypher functions.
 * @date Nov-2011
 * @author Leonardo Lino 2101101
 * @author Joaquim Ferreira 2101104
 * @version 1.0
 */

#ifndef CRYPT_H
#define CRYPT_H

extern int G_continue;
extern int G_proc_lines;

/**
 * @brief This function cypher a file from a given table.
 * @fn void cypher (const char *table, const char *filename, int type)
 * @param table A pointer to the string tablename.
 * @param filename A pointer to the string filename.
 * @param type An integer of the type (CYPHER = 1 | DECYPHER = 2).
 * @return Nothing to return
 */
void cypher (const char *table, const char *filename, int type);

/**
 * @brief This function receives a character, searches in the filetable for it then returns it's replacement.
 * @fn char letterReplace (char letter, char **array, int cntLine, int type)
 * @param letter A character
 * @param array The table with the original and the replace characters (an array of pointers).
 * @param cntLine Number of lines in the table.
 * @param type An integer of the type (CYPHER = 1 | DECYPHER = 2).
 * @return The corresponding replace character.
 */
char letterReplace (char letter, char **array, int cntLine, int type);

/**
 * @brief This function copies the characters from the table from file to the table in memory.
 * @fn char **tableLoader (const char *table, int *p_cntLine)
 * @param table The pointer of the tablename.
 * @param p_cntLine The pointer to the number of lines in the table.
 * @return The pointer to the array of pointers
 */
char **tableLoader (const char *table, int *p_cntLine);

#endif /* CRYPT_H */
